<?php include_once '../../../include/inc_session.php';

	
	if (isset($_GET['Identifiant_justificatif'])) 
	{
  		$idJustif = $_GET['Identifiant_justificatif'];
	}
	$idRole = $_GET['idrole'];
	$idContrat = $_SESSION['idcontrat'];
	
	$oJustif = new dataObject_justificatif($idJustif);
	$oContrat = new dataObject_contrat($idContrat);
	$oCdtVente = new dataObject_conditionVente();

	$idPersonne = isset($_GET['Identifiant_personne']) ? $_GET['Identifiant_personne']: $oJustif->_IDENTIFIANT_PERSONNE;
	
	$TYPE    =  (isset($_POST['Type_justificatif']))  ?  $_POST['Type_justificatif']  : $oJustif->_TYPE_JUSTIFICATIF;
	$VALEUR    =  (isset($_POST['OJU_Valeur_justificatif'])) ?  $_POST['OJU_Valeur_justificatif'] : $oJustif->_VALEUR_JUSTIFICATIF;

	if ($gbFormValid) 
	{
		$oJustif->_TYPE_JUSTIFICATIF  			= $TYPE; //'CIN';//
		$oJustif->_VALEUR_JUSTIFICATIF  		= $VALEUR;
		$oJustif->_IDENTIFIANT_CONTRAT  		= $_POST['idcontrat'];
		$oJustif->_IDENTIFIANT_PERSONNE  		= $_POST['Identifiant_personne'];
		if($idJustif == '')
		{
			$id = $oJustif->justificatif_insert();
			
			if(!$id) $oForm->ajouterErreur(chgmt_couv_crea_justif_pbm);
			else 
			{
				$oForm->ajouterErreur(justificatif_creation);
				$_SESSION['justifModifCreer'][] = $id;
			}
			
		}
		else
		{
			$id = $oJustif->justificatif_update();
			
			if($id===false) $oForm->ajouterErreur(chgmt_couv_mod_justif_pbm);
			else 
			{
				$oForm->ajouterErreur(justificatif_modif);
				$_SESSION['justifModifCreer'][] = $idJustif;
			}
		}
		//header("location:index.php?Identifiant_personne=".$idPersonne);
	}

	$nom_module_saisie="D&eacute;tail justificatif";


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Justificatif</title>
			<link rel="stylesheet" type="text/css" href="../../../css/main.css" />
            <link rel="stylesheet" type="text/css" href="list.css" />
			<!--[if IE 7]>
            	<link rel="stylesheet" type="text/css" href="../../css/ie7.css" />
            	<link rel="stylesheet" type="text/css" href="form_ie7.css" />
            <![endif]--></head>

<body>
<div id="sf_menu1">
<h3><?php echo $oBloc->_MENU_NOM ?></h3>
	<div id="information_erreur" class="false">
        <ul id="message">
        	<li><?php $aMsg =$oForm->getValidMessage(); echo (!empty($aMsg))? $aMsg[0]['message'] : ''; ?></li>
        </ul>
    </div>

</div>
<div class="cleared"></div>

<div class="corps1">
<div class="cleared"></div>
<div id="br"></div>

<form action="<?php echo $sEditFormAction; ?>" method="post" name="form2" id="form2">
<div class="imgleft"></div>
	<div class="imgmiddle">
    <div class="btn">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $oFonction->_MENU_AFFICHE; ?></h5>
        </span><span class="btnright"></span>
    </div>
  	<div class="btn1">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $nom_module_saisie; ?></h5>
        </span>
        <span class="btnright"></span>
    </div>
	<div class="formulaire">
  <table class="tabform">
    <tr>
      <td class="td1">TYPE JUSTIFICATIF</td>
      <td> <select name="Type_justificatif" id="Type_justificatif"  >
      <?php 
		$aTypeList = dataObject_elementdico::elementdico_getListFromCode(dataObject_dictionnaire::TYPE_JUSTIFICATIF);
		foreach ($aTypeList as $i => $aRow)
		{ ?>
        <option <?php  if(isset($_SESSION['Type_justificatif'])) echo remind_select1('Type_justificatif', $aRow["Code_element"]) ; else echo remind_select('Type_justificatif', $aRow["Code_element"]);?> value="<?php echo $aRow["Code_element"];?>"><?php echo $aRow["Nom_element"];?></option>
        <?php 
		}?>
        </select>
      </td>
    </tr>
    <tr >
      <td class="td1">VALEUR</td>
      <td><input name="OJU_Valeur_justificatif" type="text" value="<?php echo htmlentities($oJustif->_VALEUR_JUSTIFICATIF, ENT_COMPAT, 'utf-8'); ?>" size="32" maxlength="30" /></td>
    </tr></table> 
  
  </div>
    
 </div>

<div class="imgright"></div>				


    <div class="bt1"> <a href="index.php?Identifiant_personne=<?php echo $_GET['Identifiant_personne']?>&idcontrat=<?php echo $idContrat; ?>&idrole=<?php echo $idRole; ?>"><span class="btleft"></span>
        <span class="btmiddle">Annuler</span>
        <span class="btright"></span>
    </a></div>
    
      <div class="bt">
	<span class="btleft"></span><input type="submit" value="Valider" class="resizeall btmiddle"/>
    <span class="btright"></span></div>
    
    <div class="cleared"></div>
	 
  
  <input type="hidden" name="Identifiant_justificatif" value="<?php echo $oJustif->_IDENTIFIANT_JUSTIFICATIF; ?>" />
  <input type="hidden" name="idcontrat" value="<?php echo $idContrat; ?>" />
  <input type="hidden" name="Identifiant_personne" value="<?php echo $idPersonne; ?>" />
  <input type="hidden" name="Identifiant_evenement" value="<?php echo htmlentities($oJustif->_IDENTIFIANT_EVENEMENT, ENT_COMPAT, 'utf-8'); ?>" />
  <input type="hidden" name="Identifiant_sinistre" value="<?php echo htmlentities($oJustif->_IDENTIFIANT_SINISTRE, ENT_COMPAT, 'utf-8'); ?>" />
  <input type="hidden" name="MM_update" value="form2" />
</form>

</div>
</body>
</html>
<?php

include_once PATH_INCLUDE.'inc_pied_page.php';
?>
